<div id="page">
    <div class="page-title">
        <div class="in" style="z-index: 770;">
            <div class="titlebar" style="z-index: 760;">	
                <h2><?php echo $lang['heading_title'] ?></h2>	
            </div>
        </div>
    </div>
    <div class="content" >

        <!-- START TABLE -->
        <div class="simplebox grid740">

            <div class="titleh"><h3><?php echo $lang['heading_title'] ?></h3>
                <div class="shortcuts-icons">
                    <a class="shortcut tips" href="<?php echo admin_url('jobs/form') ?>" title="<?php echo $lang['btn_add_job'] ?>"><img src="<?php echo base_url(); ?>admin_public/img/icons/shortcut/plus.png" width="25" height="25" alt="icon" /></a>
                </div>
            </div>
            <div id="example_wrapper" class="dataTables_wrapper">
                <div class="fg-toolbar ui-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix">
                    <div id="" class="dataTables_length">
                        <?php echo $lang['text_sort'] ?>
                        <select id="sort">
                            <option value="jobs.sort_order"><?php echo $lang['text_sort_order'] ?></option>
                            <option value="jobs_description.name"><?php echo $lang['text_name'] ?></option>
                            <option value="jobs.date_added"><?php echo $lang['text_date_added'] ?></option>
                        </select>
                        <input id="asc" value="1" type="checkbox"/><?php echo $lang['text_asc'] ?>
                        &nbsp;
                        &nbsp;
                        <?php echo $lang['text_status'] ?>
                        <select id="status">
                            <option value="all"><?php echo $lang['text_all'] ?></option>
                            <option value="1"><?php echo $lang['text_active'] ?></option>
                            <option value="0"><?php echo $lang['text_deactive'] ?></option>
                        </select>
                    </div>

                    <div class="dataTables_filter" id="example_filter">
                        <label>Search: <input type="text" id="search"></label>
                    </div>
                </div>

                <div id="jobs-table">

                </div>

                <div id="navigation" class="fg-toolbar ui-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix">
                </div>
            </div>
        </div>
        <!-- END TABLE -->

    </div>

</div>


<script type="text/javascript">
    function isEmpty(str) {
        return (!str || 0 === str.length);
    }
    
    function active(id){
        $.ajax({  
            url:"<?php echo admin_url('jobs/active') ?>/"+id,
            success: function(data){
                $('#status'+id).html('<a href="javascript:de_active('+id+')" title="<?php echo $lang['text_deactive'] ?>"><img src="<?php echo base_url() ?>/admin_public/img/delete-file-icon.png"</a>')
                $('#stt'+id).html('<?php echo $lang['text_active'] ?>')
            } 
        })
    }
    function de_active(id){
        $.ajax({  
            url:"<?php echo admin_url('jobs/deactive') ?>/"+id,
            success: function(data){
                $('#status'+id).html('<a href="javascript:active('+id+')" title="<?php echo $lang['text_deactive'] ?>"><img src="<?php echo base_url() ?>/admin_public/img/folder-add-icon.png"</a>')
                $('#stt'+id).html('<?php echo $lang['text_deactive'] ?>')
            } 
        })
    }
    function search(page) {
        var search = $('#search').val();           
        var sort = $('#sort').val();
        var asc = $('#asc:checked').val();
        var status = $('#status').val();
        
        if(isEmpty(page)){
            var page = '<?php echo admin_url('jobs/lists') ?>';
        }
        $.ajax({  
            type:"post",
            data: {search: search,sort:sort,asc:asc,page:page,status:status},
            url:page,
            success: function(data){
                var obj = jQuery.parseJSON(data);                                      
                $('#jobs-table').html(obj.jobs);
                $("#navigation").html(obj.links);  
            } 
        }); 
    }
    
    $('.nav-page a,.nav-button a').live('click',function(){
        search($(this).attr('href'));
        return false;
    })
    
        
    $(document).ready(function(){
        search();
        
        $('#search').keyup(function(){
            search();
        });
        
        $('#sort').change(function(){
            search();
        });
        $('#status').change(function(){
            search();
        });
        $('#asc').change(function(){
            search();
        });
    })
</script>